package com.example.hello.client.NavLink;

import com.example.hello.BootstrapNavLink;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;

@Connect(BootstrapNavLink.class)
public class BootstrapNavLinkConnector extends AbstractComponentConnector {

    @Override
    protected Widget createWidget() {
        return GWT.create(VBootstrapNavLink.class);
    }

    @Override
    public BootstrapNavLinkState getState() {
        return (BootstrapNavLinkState) super.getState();
    }

    @Override
    public VBootstrapNavLink getWidget() {
        return (VBootstrapNavLink) super.getWidget();
    }

    @Override
    public void onStateChanged(StateChangeEvent stateChangeEvent) {
        super.onStateChanged(stateChangeEvent);

        BootstrapNavLinkState state = getState();

        VBootstrapNavLink navLink = getWidget();

        navLink.setText(getState().getText());
        navLink.setHref(getState().getHref());
        navLink.setTarget(getState().getTarget());
    }

}